package cn.com.epicc.wap.epe.product.controller;

import cn.com.epicc.wap.epe.common.result.Result;
import cn.com.epicc.wap.epe.product.service.ProductService;
import cn.com.epicc.wap.epe.product.vo.PageVo;
import cn.com.epicc.wap.epe.product.vo.ProductVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * Description: 产品服务控制层
 * Author: lishangmin
 * Created: 2018-06-06 16:55
 */
@Api("产品服务API")
@Slf4j
@RestController
public class ProductController {

    @Autowired
    ProductService productService;

    @ApiOperation("产品查询")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "productKey", value = "产品主键" , paramType = "query"),
            @ApiImplicitParam(name = "productName", value = "产品名称", paramType = "query"),
            @ApiImplicitParam(name = "type", value = "类型", paramType = "query"),
            @ApiImplicitParam(name = "status", value = "状态", paramType = "query"),
            @ApiImplicitParam(name = "page", value = "页码", required = true,paramType = "query"),
            @ApiImplicitParam(name = "pageSize", value = "页长", required = true,paramType = "query")
    })
    @RequestMapping(value = "/list",method = RequestMethod.GET)
    public Result<PageVo<ProductVo>> list(
            @RequestParam(value = "productKey",required = false)String productKey,
            @RequestParam(value = "productName",required = false)String productName,
            @RequestParam(value = "type",required = false)String type,
            @RequestParam(value = "status",required = false)String status,
            @RequestParam("page") int page,
            @RequestParam("pageSize") int pageSize
    ){
        return Result.success(new PageVo<>());
    }

    @ApiOperation("创建产品")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "productName", value = "产品名称", required = true,paramType = "form"),
            @ApiImplicitParam(name = "type", value = "类型", required = true,paramType = "form"),
            @ApiImplicitParam(name = "version", value = "版本号", required = true,paramType = "form"),
            @ApiImplicitParam(name = "url", value = "URL", required = true,paramType = "form"),
            @ApiImplicitParam(name = "productCode", value = "产品代码", required = true,paramType = "form")
    })
    @RequestMapping(value = "/add",method = RequestMethod.POST)
    public Result<ProductVo> add(
            @RequestParam(value = "productName")String productName,
            @RequestParam(value = "type")String type,
            @RequestParam(value = "version")String version,
            @RequestParam(value = "url")String url,
            @RequestParam(value = "productCode")String productCode
    ){
        productService.add();
        return Result.success(new ProductVo());
    }

    @ApiOperation("产品复制")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "productKey", value = "产品主键" ,required = true,paramType = "form")
    })
    @RequestMapping(value = "/copy",method = RequestMethod.POST)
    public Result<ProductVo> copy(
            @RequestParam(value = "productName")String productName
    ){
        return Result.success(new ProductVo());
    }

}
